package org.jfedor.nxtremotecontrol;

import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import android.util.Log;

public class NxtRemoteService extends Service{

	private NXTConnector nc = null;
	
	public void onCreate() {
		super.onCreate();
	}
	
	public void onDestroy() {
		super.onDestroy();
	}
	
	@Override
	public IBinder onBind(Intent intent) {
		// TODO Auto-generated method stub
		return mBinder;
	}

	NXT.Stub mBinder = new NXT.Stub() {
		
		@Override
		public String connect() throws RemoteException {
			Log.d("andIntent","connect()");
			nc = new NXTConnector(mHandler);
			nc.start();
			return "connect() called";
		}
		@Override
		public String disconnect() throws RemoteException {
			Log.d("andIntent","disconnect()");
			return "disconnect() called";
		}
		@Override
		public int getStatus() throws RemoteException {
			Log.d("andIntent","getStatus()");
			return nc.getmNXTTalker().getState();
		}
		@Override
		public String dance() throws RemoteException {
			Log.d("andIntent","dance()");
			Dance dance = new Dance(nc.getmNXTTalker());
			return dance.start();
		}
		@Override
		public void sendKey(String key) throws RemoteException {
			Log.d("andIntent","sendKey()");
		};
	};
	
    private final Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
        }
    };	
}
